package com.googlecode.imanager.client.form;

import java.io.Serializable;

import com.googlecode.imanager.client.util.UniqueList;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class CheckGroup extends UniqueList<InputCheck> implements Serializable {

    private static final long serialVersionUID = 1L;

    public CheckGroup() {
        super();
    }

    public CheckGroup(int initialCapacity) {
        super(initialCapacity);
    }

    @Override
    protected void onAfterAdd(int index, InputCheck item) {
        item.setGroup(this);
    }

    @Override
    protected void onAfterRemove(int index, InputCheck item) {
        item.setGroup(null);
    }

    @Override
    protected void onAfterReplace(int index, InputCheck oldItem, InputCheck newItem) {
        onAfterAdd(index, newItem);
    }

    @Override
    protected void onBeforeReplace(int index, InputCheck oldItem, InputCheck newItem) {
        onBeforeRemove(index, oldItem);
        onBeforeAdd(index, newItem);
        onAfterRemove(index, oldItem);
    }
    
}
